<include file="Public/header"/>
<style>.gybtn {
    position: absolute;
    right: 10px;
    margin-top: 10px;
}</style>
<div class="panel panel-default row no-borders">
    <div class="panel-heading" style="background: #fafafa;">
        <h5 class="panel-title text-center"><i class="fa fa-edit"></i> 修改订单信息</h5>
    </div>
</div>
<div class="wrapper m-t">
    <div class="panel panel-primary">
        <div class="panel-heading no-padding">
            <div class="panel-options">
                <ul class="nav nav-tabs no-borders">
                    <li><a href="{:U('Orders/orderUpdate?rid='.$rid)}">订单信息</a></li>
                    <li><a href="{:U('Orders/updateProduct?rid='.$rid)}">产品信息</a></li>
                    <li><a href="{:U('Orders/updateCraft?rid='.$rid)}">工序信息</a></li>
                    <li class="active"><a href="{:U('Orders/updateMaterial?rid='.$rid)}">原材料信息</a></li>
                </ul>
            </div>
        </div>
        <div class="panel-body" style="position: relative;">
            <div class="tab-content">
                <div class="tab-pane active">
                    <form class="form-horizontal form-ma" id="formvalidate" action="{:U('Orders/updateMaterial?rid='.$rid)}" method="post">
                        <h3 class="pull-left">【请在输入框输入原材料的编码或名称进行搜索】</h3>
                        <div class="input-group pull-right" style="width: 300px;">
                            <input type="text" class="form-control" id="search">

                            <span class="input-group-addon search bg-info"><i class="fa "></i> 添  加</span>

                            <div class="input-group-btn">
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                </ul>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <div class="hr-line-dashed"></div>

                        <div id="cailiao" class="m-t">

                            <volist name="_list" id="vo">
                                <div class="cailiaobox">
                                    <div class="col-lg-2">
                                        <div class="input-group m-b">
                                            <input type="hidden" value="{$vo.om_id}" name="om_id[]"/>
                                            <span class="input-group-addon">编号</span>
                                            <input type="text" class="form-control" disabled value="{$vo.m_number}"
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="col-lg-2">
                                        <div class="input-group m-b">
                                            <span class="input-group-addon">名称</span>
                                            <input type="text" class="form-control" disabled value="{$vo.m_name}"
                                                   readonly="readonly"></div>
                                    </div>
                                    <div class="col-lg-2">
                                        <div class="input-group m-b">
                                            <span class="input-group-addon">规格</span>
                                            <input type="text" class="form-control" disabled value="{$vo.standard}"
                                                   readonly="readonly"></div>
                                    </div>
                                    <div class="col-lg-2">
                                        <div class="input-group m-b date">
                                            <span class="input-group-addon">价格</span>
                                            <input type="text" class="form-control" disabled value="{$vo.sell_price}"
                                                   readonly="readonly"></div>
                                    </div>
                                    <div class="col-lg-2">
                                        <div class="input-group m-b date">
                                            <span class="input-group-addon">条形码</span>
                                            <input type="text" class="form-control"  disabled
                                                   value="{$vo.bracode}"></div>
                                    </div>
                                    <input type="hidden"  name="bracode[]" value="{$vo.bracode}">
                                    <div class="col-lg-2">
                                        <div class="input-group m-b date">
                                            <span class="input-group-addon">数量</span>
                                            <input type="text" class="form-control" name="counts[]"
                                                   value="{$vo.counts}"></div>
                                    </div>

                                    <a href="{:U('Orders/mdels?om_id='.$vo[om_id])}" class="ajax-get confirms">
                                        <div class="gybtn"><span class=" pull-right">
                                    <i class="glyphicon glyphicon-remove-sign text-info"></i></span>
                                        </div>
                                    </a>

                                    <div class="clearfix"></div>
                                </div>
                            </volist>


                        </div>

                        <div class="form-group">
                            <input type="button" target-form="form-ma" class="ajax-post btn btn-primary col-lg-1 col-lg-push-5 m-t-lg" value="提交"/>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<include file="Public/footer"/>
<script src="__PUBLIC__/Admin/js/tianchen.js"></script>
<script src="__PUBLIC__/Admin/js/bootstrap-suggest.min.js"></script>
<script src="__PUBLIC__/Admin/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script>

    $('.search').click(function () {
        var keywords = $("#search").val();
        if (keywords == '') {
            layer.alert('请输入关键词');
            return;
        }
        var data = '';
        $.post("{:U('Stock/search')}", {keywords: keywords}, function (re) {
            if (re.state == 'success') {
                var info = re.info;
                data += '<div class="cailiaobox">';
                data += '<div class="col-lg-2"><div class="input-group m-b">';
                data += '<span class="input-group-addon">编号</span>';
                data += '<input type="text" class="form-control" readonly="readonly" value="' + info.m_number + '"></div></div>';
                data += '<div class="col-lg-2"><div class="input-group m-b">';
                data += '<span class="input-group-addon">名称</span>';
                data += '<input type="text" class="form-control" readonly="readonly" value="' + info.m_name + '"></div></div>';
                data += '<div class="col-lg-2"><div class="input-group m-b">';
                data += '<span class="input-group-addon">规格</span>';
                data += '<input type="text" class="form-control" readonly="readonly" value="' + info.standard + '"></div></div>';
                data += '<div class="col-lg-2"><div class="input-group m-b date">';
                data += '<span class="input-group-addon">价格</span>';
                data += '<input type="text" class="form-control" readonly="readonly" value="' + info.bid_price + '"></div></div>';
                data += '<div class="col-lg-2"><div class="input-group m-b date">';
                data += '<span class="input-group-addon">条码</span>';
                data += '<input type="text" class="form-control" readonly="readonly" name="bracode[]" value="' + info.bracode + '"></div></div>';
                data += '<div class="col-lg-2"><div class="input-group m-b date">';
                data += '<span class="input-group-addon">数量</span>';
                data += '<input type="text" class="form-control" name="counts[]" value="1"></div></div>';
                data += '<div class="gybtn"><span class="closebtn pull-right"><i class="glyphicon glyphicon-remove-sign text-info"></i></span></div>';
                data += '<div class="clearfix"></div></div>';
                $('#cailiao').append(data);
            } else {
                layer.alert('没有这个货品');
                return;
            }
        })


    });

    function initTest() {
        $("#search").bsSuggest('init', {
            allowNoKeyword: false,
            getDataMethod: 'firstByUrl',
            url: "{:U('Stock/test')}",
            idField: "userId",
            keyField: "userName"
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword, data) {
            console.log('onSetSelectValue: ', keyword, data);
        }).on('onUnsetSelectValue', function () {
            console.log('onUnsetSelectValue');
        });
    }

    initTest()
</script>

